﻿@model Ecommerce.Areas.Manager.Models.Product
@{
    ViewBag.Title = "Edit a product";
}
<p>
    @Html.ActionLink("Back to List", "Index")
</p>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.ProductID)
    <fieldset>
        <legend>Regist a category</legend>
        <p class="field-validation-error">
            @ViewBag.ErrorMsg
        </p>
        <div class="editor-label">
            @Html.LabelFor(model => model.CategoryId)
        </div>
        <div class="editor-field">
            @if (Model.CategoryList != null)
            {
                @Html.DropDownListFor(model => model.CategoryId, new SelectList(Model.CategoryList, "CategoryID", "CategoryName"))
                @Html.ValidationMessageFor(model => model.CategoryId)
            }
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ProdName)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.ProdName)
            @Html.ValidationMessageFor(model => model.ProdName)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Price)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Price)
            @Html.ValidationMessageFor(model => model.Price)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ProductStatus)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ProductStatus, Enum.GetValues(typeof(Ecommerce.Common.EcommerceEnum.ProductStatus))
                                                                .Cast<Ecommerce.Common.EcommerceEnum.ProductStatus>()
                                                                .Select(v => new SelectListItem
                                                                {
                                                                    Text = v.ToString(),
                                                                    Value = ((int)v).ToString()
                                                                }))
            @Html.ValidationMessageFor(model => model.ProductStatus)
        </div>
        <p>
            <button type="submit">Submit</button>
        </p>
    </fieldset>
}
